package yawning.mew;

import java.lang.reflect.Field;
import java.util.ArrayList;

public class MewProperty {
	public MewProperty(String key, Object defValue) {
		mKey = key;
		mDefValue = defValue;
	}
	
	String getKey() {
		return mKey;
	}
	
	Object getDefault() {
		return mDefValue;
	}
	
	public static MewProperty[] getProperties(Class<?> c) {
		ArrayList<MewProperty> properties = new ArrayList<MewProperty>();
		for (Field f : c.getFields()) {
			try {
				if (f.getType() == MewProperty.class) properties.add((MewProperty)f.get(null));
			}
			catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return properties.toArray(new MewProperty[0]);
	}
	
	private String mKey;
	private Object mDefValue;
}
